package com.ysd.controller;

import java.util.List;

import org.hibernate.stat.Statistics;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ysd.entity.Statistcs;
import com.ysd.repository.StatistcsRepository;
import com.ysd.utils.Result;



@RestController
public class StatisticsController {
	@Autowired
	private StatistcsRepository sRepository;
	
	@RequestMapping("findSta")
	public Object findSta() {
		List<Statistcs>list=sRepository.findAll();
		long number=sRepository.count();
		int count=(int)(number);
		if (list!=null) {
			return Result.toClient("0", "有数据",count,list);
		} else {
			return Result.toClient("1", "无数据",null,null);
		}
	}    
	
	@RequestMapping("findStas")
	public Object findStas() {
		List<Statistcs>list=sRepository.findAll();
		long number=sRepository.count();
		int count=(int)(number);
		if (list!=null) {
			return Result.toClient("0", "有数据",count,list);
		} else {
			return Result.toClient("1", "无数据",null,null);
		}
	}
	
	@RequestMapping("getStatis")
	public Object getStatis() {
		List<Object> list=sRepository.getStatis();
	
			if (list!=null) {
				return Result.toClient("0", "有数据",0,list);
			} else {
				return Result.toClient("1", "无数据",null,null);
			}
	}
	
	@RequestMapping("getStatisName")
	public Object getStatisName() {
		List<Object>	list=sRepository.getStatisName();
			
		if (list!=null) {
			return Result.toClient("0", "有数据",0,list);
		} else {
			return Result.toClient("1", "无数据",null,null);
		}
		
	}
	
	@RequestMapping("getStatisXi")
	public Object getStatisXi() {
		List<Object>	list=sRepository.getstatisdepartment();
		
		if (list!=null) {
			return Result.toClient("0", "有数据",0,list);
		} else {
			
			return Result.toClient("1", "无数据",null,null);
		}
		
	}
	
	@RequestMapping("getStatisZhuanYe")
	public Object getStatisZhuanYe() {
		List<Object>	list=sRepository.getStatisZhuanYe();
		
		if (list!=null) {
			return Result.toClient("0", "有数据",0,list);
		} else {
			
			return Result.toClient("1", "无数据",null,null);
		}
		
	}
	
	@RequestMapping("getStatisNianJi")
	public Object getStatisNianJi() {
		List<Object>	list=sRepository.getStatisNianJi();
		
		if (list!=null) {
			return Result.toClient("0", "有数据",0,list);
		} else {
			
			return Result.toClient("1", "无数据",null,null);
		}
		
	}
}
